package top.xierongsheng.utlis.data;

/**
 * @author: zqz
 * @date: 2019-01-09 10:55
 * @description:
 * @version:
 */
public class ObjectUtil {
    /**
     * Object转String
     *
     * @param obj
     * @return
     */
    public static String toString(Object obj) {
        return (obj == null) ? null : obj.toString();
    }

    /**
     * Object转Integer
     *
     * @param obj
     * @return
     */
    public static Integer toInteger(Object obj) {
        return (obj == null) ? null : Integer.valueOf(obj.toString());
    }

    /**
     * Object转Long
     *
     * @param obj
     * @return
     */
    public static Long toLong(Object obj) {
        return (obj == null) ? null : Long.valueOf(obj.toString());
    }

    /**
     * Object转String
     *
     * @param obj
     * @return
     */
    public static Integer getLength(Object obj) {
        return (obj == null) ? 0 : obj.toString().length();
    }

    /**
     * Object转Boolean
     *
     * @param obj
     * @return
     */
    public static Boolean toBoolean(Object obj) {
        return (obj == null) ? false : Boolean.valueOf(obj.toString());
    }
}
